#include "udpclient.h"

UDPClient::UDPClient() {

}

void UDPClient::sendScanMsg(Scan * scan){
    QByteArray data = Scan::enCodeToJson(scan);
    QUdpSocket udpSocket;
    QString brocastStr = NetAction::getBroadcastAddresses();
    QHostAddress brocastAddr(brocastStr);
    qint64 bytesWriten = udpSocket.writeDatagram(data,brocastAddr,UDPPort);
    if(-1 == bytesWriten){
        QDEBUG_FILE_FUNC<<"failed to send scan msg";
    }else{
        QDEBUG_FILE_FUNC<<"scan msg send successfully ,bytes written : "<<bytesWriten;
    }
}
